package com.faithbj.process;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * User: xiongyuanwei
 * Date: 12-7-17
 * Time: 下午8:38
 */
public class StateFactory {

    private static Map<String, State> mapping = Maps.newHashMap();
    private static Map<String, State> mapping2 = Maps.newHashMap();
    private static Map<Long, State> mapping3 = Maps.newHashMap();

    static {
        for (State state : State.values()) {
            mapping.put(state.getNodeName(), state);
            mapping2.put(state.getName(), state);
            mapping3.put(state.getId(), state);
        }
    }

    public static State getStateByNodeName(String nodeName) {
        return mapping.get(nodeName);
    }

    public static State getStateByTaskName(String taskName) {
        return mapping2.get(taskName);
    }

    public static State getStateById(long stateId) {
        return mapping3.get(stateId);
    }
}
